package com.lt.utils;

import java.util.ArrayList;

/**
 * @author LiuTong
 */
public class StringSubsection {
    private static StringSubsection stringSubsection;
    private ArrayList<String> arraySubsection;

    public StringSubsection() {

    }

    /***根据数量分割*******/
    public ArrayList<String> getStringSubsection(String str) {
        arraySubsection = new ArrayList<String>();
        int contentLength = str.length();
        if (contentLength < 60) {
            arraySubsection.add(str);
        } else {

            int begin = 0;
            int cutCount = contentLength / 60;//总共判断个数
            int cutCounts = contentLength % 60;

            if (cutCounts != 0) { //剩余长度
                cutCount++;
            }

            for (int i = 1; i <= cutCount; i++) {
                String temp;
                // 不是最后一段
                if (i != cutCount) {
                    temp = str.substring(begin, 60 * i);
                } else {
                    temp = str.substring(begin, contentLength);
                }

                begin = 60 * i;
                arraySubsection.add(temp);
            }
        }
        return arraySubsection;
    }

    /***************根据标点分割****/
    public ArrayList<String> getStringSpilt(String str) {
        String[] strings = new String[]{};
        int lenth = 0;
        arraySubsection = new ArrayList<String>();
        strings = str.split("。|;|:|，|,|、");
        lenth = strings.length;
        for (int i = 0; i < lenth; i++) {
            arraySubsection.add(strings[i]);
        }
        return arraySubsection;
    }


}
